package com.clusterswisdom.horn.api.tmall.action.item;

import java.sql.Connection;
import java.sql.PreparedStatement;

import com.alibaba.fastjson.JSONObject;
import com.clusterswisdom.horn.api.db.DbUtil;
import com.clusterswisdom.horn.api.ioc.HornAction;
import com.clusterswisdom.horn.api.ioc.HornResponse;
import com.clusterswisdom.horn.api.ioc.api.ApiConfig;
import com.clusterswisdom.horn.api.tmall.action.AbstractTmallAction;

public class DeleteSomeItemAction extends AbstractTmallAction implements HornAction{
	@Override
	public HornResponse execute(ApiConfig config, JSONObject param)
			throws Exception {
		Connection con = DbUtil.getUtil().getConnection();
		try{
			String sql = "delete from itemsforsetting where cai = ?";
			PreparedStatement ps = con.prepareStatement(sql);
			ps.setString(1, param.getString("cai"));
			ps.execute();
			ps.close();
		}catch(Exception e){
			DbUtil.getUtil().rollback();
			return new HornResponse(false, "失败");
		}finally{
			DbUtil.getUtil().commit();
		}
		return new HornResponse(true, "成功");
	}
}
